package com.wanghua.mall.order.listener;

import com.rabbitmq.client.Channel;
import com.wanghua.mall.order.config.OrderRabbitMQConfig;
import com.wanghua.mall.order.entity.OrderEntity;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

import java.io.IOException;

/**
 * @author wanghua
 * @create 2021-09-10 13:27
 */
@RabbitListener(queues = OrderRabbitMQConfig.ORDER_RELEASE_ORDER_QUEUE_NAME)
public class OrderRabbitMQListener {

    @RabbitHandler
    public void test(Message message, OrderEntity orderEntity, Channel channel) throws IOException {
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        System.out.println("收到消息了：" + orderEntity);

    }
}
